<?php

namespace common\models\qywx;

use Yii;

/**
 * This is the model class for table "qywx_department".
 *
 * @property integer $id
 * @property string $number
 * @property string $name
 * @property integer $wx_id
 * @property integer $parent_wx_id
 * @property integer $order
 * @property string $memo
 * @property string $created_by
 * @property string $created_at
 * @property string $updated_by
 * @property string $updated_at
 */
class QywxDepartment extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'qywx_department';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name', 'wx_id'], 'required'],
            [['wx_id', 'parent_wx_id', 'order'], 'integer'],
            [['created_at', 'updated_at'], 'safe'],
            [['number', 'name'], 'string', 'max' => 255],
            [['memo'], 'string', 'max' => 1024],
            [['created_by', 'updated_by'], 'string', 'max' => 45],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'number' => Yii::t('app', 'Number'),
            'name' => Yii::t('app', 'Name'),
            'wx_id' => Yii::t('app', 'Wx ID'),
            'parent_wx_id' => Yii::t('app', 'Parent Wx ID'),
            'order' => Yii::t('app', 'Order'),
            'memo' => Yii::t('app', 'Memo'),
            'created_by' => Yii::t('app', 'Created By'),
            'created_at' => Yii::t('app', 'Created At'),
            'updated_by' => Yii::t('app', 'Updated By'),
            'updated_at' => Yii::t('app', 'Updated At'),
        ];
    }

    public function getPrintName(){
        return sprintf('部门: %s', $this->name);
    }
}
